package com.yulongtian.oneProblemEveryDay.month202301;

/**
 * https://leetcode.cn/problems/greatest-english-letter-in-upper-and-lower-case/
 * 可
 *
 * @author yulongTian
 * @create 2023-01-27 0:05
 */
public class Test18 {
    public static void main(String[] args) {

    }

    public static String greatestLetter(String s) {
        int[] big = new int[26];
        int[] small = new int[26];
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c >= 'a' && c <= 'z') {
                small[c - 'a']++;
                continue;
            }
            if (c >= 'A' && c <= 'Z') {
                big[c - 'A']++;
            }
        }
        for (int i = 25; i >= 0; i--) {
            if (small[i] > 0 && big[i] > 0) {
                return "" + (char) ('A' + i);
            }
        }
        return "";
    }
}
